package com.homework.ch08;

import java.util.Comparator;
import java.util.TreeSet;

public class Test7 {
    public static void main(String[] args) {
        TreeSet<Student> set=new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                boolean one="tom".equals(o1.getName());
                boolean two="tom".equals(o2.getName());
                if(one&&!two)
                {
                    return -1;
                }
                if(!one&&two)
                {
                    return 1;
                }
                return (int)(o1.getScore()-o2.getScore());
            }
        });
        set.add(new Student("bob",70));
        set.add(new Student("hello",80));
        set.add(new Student("tom",40));
        set.add(new Student("tom",10));
        System.out.println(set);

    }
}
